Number | NN 3 IE J2 ECMA 1 |
A Number object represents any numerical value, whether it is an integer or floating-point number. By and large, you don't have to worry about the Number object because a numerical value automatically becomes a Number object instance whenever you use such a value or assign it to a variable. On the other hand, you might want access to the static properties that only a math major would love. | |
Creating a Number Objectvar myValue = number var myValue = new Number(number) |
MAX_VALUE | NN 3 IE J2 ECMA 1 |
Read-only | |
Equal to the highest possible number that JavaScript can handle. | |
Examplevar tiptop = Number.MAX_VALUE | |
Value 1.7976931348623157e+308 |
MIN_VALUE | NN 3 IE J2 ECMA 1 |
Read-only | |
Equal to the smallest possible number that JavaScript can handle. | |
Examplevar itsybitsy = Number.MIN_VALUE | |
Value 5e-324 |
NaN | NN 3 IE J2 ECMA 1 |
Read-only | |
Equal to a value that is not-a-number. JavaScript returns this value when a numerical operation yields a non-numerical result because of a flaw in one of the operands. If you want to test whether a value is not a number, use the isNaN() global function rather than comparing to this property value. | |
Value NaN |
NEGATIVE_INFINITY, POSITIVE_INFINITY | NN 3 IE J2 ECMA 1 |
Read-only | |
Values that are outside of the bounds of Number.MIN_VALUE and Number.MAX_VALUE, respectively. | |
ExampleNumber.NEGATIVE_INFINITY | |
Value -Infinity; Infinity |
prototype | NN 3 IE J2 ECMA 1 |
Read/Write | |
A property of the static Number object. Use the prototype property to assign new properties and methods to future instances of a Number value created in the current document. See the Array.prototype property description for examples. There is little need to create new prototype properties or methods for the Number object. | |
ExampleNumber.prototype.author = "DG" | |
Value Any data, including function references. |
toString() | NN 4 IE J3 ECMA 1 |
Returns the object's value as a string data type. You don't need this method in practice because the browsers automatically convert Number values to strings when they are needed for display in alert dialogs or in-document rendering. | |
Returned Value String. | |
Parameters None. |
valueOf() | NN 4 IE J3 ECMA 1 |
Returns the object's value. | |
Returned Value A numeric value. | |
Parameters None. |